home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 3239 / 3239.xpi / chrome / inbasicph.jar / content / jOptions.js < prev    next >
Text File  |  2009-07-22  |  21KB  |  452 lines

  1. const PHPROXY_PHPROXY_EXTENSION_TEST_SERVER_URL = '/index.php?q=aHR0cDovL2luYmFzaWMubW96ZGV2Lm9yZy9yb290L2V4dDEvdXBkYXRlX21lKDMpL3Rlc3RzZXJ2ZXIudHh0%3D\&hl=3ed';
  2. const PHPROXY_EXTENSION_TEST_PhProxy04_SERVER_URL = '/index.php?q=aHR0cDovL2luYmFzaWMubW96ZGV2Lm9yZy9yb290L2V4dDEvdXBkYXRlX21lKDMpL3Rlc3RzZXJ2ZXIudHh0-\&hl=1111101001';
  3.  
  4. var PhProxy_options = {
  5.     stringsBundle : null,
  6.     
  7.     initilize : function () {
  8.       
  9.       this.stringsBundle = document.getElementById("Ph.Option.Bundle");
  10.       
  11.       switch (PhProxy_prefs.read_str('PrType')) {
  12.         case "0": strType="0.4"; break; 
  13.         case "2": strType="Glype1"; break; 
  14.         case "3": strType="Glype2"; break; 
  15.         default:  strType="0.5b2";
  16.       }  
  17.       
  18.       document.getElementById('Ph.Option.Tab1.Tab1.lblURL').value =
  19.         this.stringsBundle.getString('lbl1Tab1') + '  ' + PhProxy_prefs.read_str('curURL');
  20.       document.getElementById('Ph.Option.Tab1.Tab1.lblType').value =
  21.         this.stringsBundle.getString('lbl2Tab1') + '  ' + strType;
  22.  
  23.       document.getElementById('PhtxtURL').value = this.stringsBundle.getString('txtTab1');
  24.       
  25.       const sCntr = PhProxy_prefs.read_str('Contr').split('|');  
  26.       for (var i = 0 ; i < 8; i++)
  27.         document.getElementById('Ph.Option.Tab2.Check' + (i + 1)).checked=sCntr[i]-'0';
  28.       
  29.       document.getElementById('Ph.Option.Tab2.Check15').checked = PhProxy_prefs.read_bool('youTubeV');
  30.  
  31.       const sURL = PhProxy_prefs.read_str('sURL').split('|');  
  32.       for (i = 0 ; i < 8; i++) {
  33.         document.getElementById('menu0' + (i + 1)).label=sURL[2 * i];
  34.         document.getElementById('menu0' + (i + 1)).value=sURL[2 * i + 1];
  35.       }
  36.       
  37.       document.getElementById('Ph.Option.Tab2.Radio1').selectedIndex = parseInt(PhProxy_prefs.read_str('showAddressbar'));
  38.       
  39.       for (i = 0 ; i < 8; i++) {
  40.         document.getElementById('Ph.Option.Tab3.lst' + (i + 1)).getElementsByTagName('listcell').item(0).setAttribute('label',sURL[2 * i]);
  41.         document.getElementById('Ph.Option.Tab3.lst' + (i + 1)).getElementsByTagName('listcell').item(1).setAttribute('label',sURL[2 * i + 1]);
  42.       }
  43.  
  44.       document.getElementById('Ph.Option.Tab2.Radio2').selectedIndex = parseInt(PhProxy_prefs.read_str('dServerUpdate'));
  45.  
  46.       document.getElementById('Ph.Option.Tab5.RadioG').selectedIndex=parseInt(PhProxy_prefs.read_str('infoShow'));
  47.       
  48.       if (PhProxy_prefs.read_str('infoShow') == '0')
  49.         document.getElementById('PhStatusIMG').src='chrome://inbasicph/skin/InStatus.png';
  50.       else if (PhProxy_prefs.read_str('infoShow') == '1')
  51.         document.getElementById('PhStatusIMG').src='chrome://inbasicph/skin/InPopUp.png';
  52.         
  53.       document.getElementById('Ph.Option.Tab6.RadioG').selectedIndex=parseInt(PhProxy_prefs.read_str('LeftClick'));
  54.     },    
  55.     
  56.     address_textbox : {        
  57.         onfocus : function (value) {
  58.         
  59.           if (value == PhProxy_options.stringsBundle.getString('txtTab1')) 
  60.             document.getElementById('PhtxtURL').value = '';
  61.         },
  62.         onchange : function () {
  63.           //Disabling suggest server button;
  64.           document.getElementById('Ph.Option.Tab1.Tab2.button1').disabled = true;
  65.           //
  66.           var value = document.getElementById("PhtxtURL").value;
  67.           if ( value != PhProxy_options.stringsBundle.getString('txtTab1') && value ){
  68.             if( value.substr(-1) != "/" ) 
  69.               value += "/";
  70.             document.getElementById("Ph.Option.Tab1.Tab2.lbl").value = value;
  71.           }
  72.           else
  73.             document.getElementById("Ph.Option.Tab1.Tab2.lbl").value = "";
  74.         },
  75.         onblure : function (value) {
  76.           if (!value) 
  77.             document.getElementById('PhtxtURL').value = PhProxy_options.stringsBundle.getString('txtTab1');
  78.         }
  79.     },
  80.     
  81.     test_server : function () {
  82.       //Disabling suggest server button;
  83.       document.getElementById('Ph.Option.Tab1.Tab2.button1').disabled = true;
  84.       //
  85.       var sURL = document.getElementById("Ph.Option.Tab1.Tab2.lbl").value;
  86.       
  87.       if (!sURL) {
  88.         var notificationbox = document.getElementById('notProxySetup');      
  89.         notificationbox.removeAllNotifications("true"); //Remove all notifications
  90.         notificationbox.appendNotification(this.stringsBundle.getString('Alert6'),'','',notificationbox.PRIORITY_CRITICAL_BLOCK);
  91.         return;
  92.       }
  93.       
  94.       document.getElementById("Ph.Option.Tab1.Tab2.server1").value = this.stringsBundle.getString('serverMSG2');
  95.       document.getElementById("Ph.Option.Tab1.Tab2.server2").value = this.stringsBundle.getString('serverMSG2');
  96.       
  97.       var req1 = new XMLHttpRequest();
  98.       var req2 = new XMLHttpRequest();
  99.       
  100.       /* Test PhProxy 0.5b2 */
  101.       req1.open('GET', sURL + PHPROXY_PHPROXY_EXTENSION_TEST_SERVER_URL , true); /* 3rd argument, true, marks this as async */
  102.       req1.channel.loadFlags |= Components.interfaces.nsIRequest.LOAD_BYPASS_CACHE; 
  103.       req1.onreadystatechange = function (aEvt) {
  104.         if (req1.readyState == 4) {
  105.           if(req1.status == 200 && req1.responseText=="Test OK!"){
  106.             document.getElementById("Ph.Option.Tab1.Tab2.server2").value = PhProxy_options.stringsBundle.getString('serverMSG4');
  107.             document.getElementById('Ph.Option.Tab1.Tab1.pop').selectedIndex = 0;
  108.             //Enabling suggest server button on test successful for 0.5b2;
  109.             document.getElementById('Ph.Option.Tab1.Tab2.button1').disabled = false;
  110.           }
  111.           else
  112.             document.getElementById("Ph.Option.Tab1.Tab2.server2").value = PhProxy_options.stringsBundle.getString('serverMSG3');
  113.         }
  114.       };
  115.       req1.send(null);
  116.       
  117.       /* Test PhProxy 0.4 */
  118.       req2.open('GET', sURL + PHPROXY_EXTENSION_TEST_PhProxy04_SERVER_URL , true); /* 3rd argument, true, marks this as async */
  119.       req2.channel.loadFlags |= Components.interfaces.nsIRequest.LOAD_BYPASS_CACHE; 
  120.       req2.onreadystatechange = function (aEvt) {
  121.         if (req2.readyState == 4) {
  122.           if(req2.status == 200 && req2.responseText=="Test OK!"){
  123.             document.getElementById("Ph.Option.Tab1.Tab2.server1").value = PhProxy_options.stringsBundle.getString('serverMSG4');
  124.             document.getElementById('Ph.Option.Tab1.Tab1.pop').selectedIndex = 1;
  125.           }
  126.           else
  127.             document.getElementById("Ph.Option.Tab1.Tab2.server1").value = PhProxy_options.stringsBundle.getString('serverMSG3');
  128.         }
  129.       };
  130.       req2.send(null);
  131.     },
  132.     
  133.     suggesting_server: function () {
  134.         var server = document.getElementById("Ph.Option.Tab1.Tab2.lbl").value;
  135.         const fun = PhProxy_prefs.read_str("Server") + "?request=suggest&url=";
  136.         var req = new XMLHttpRequest();
  137.         req.open("GET", fun + server, true);
  138.         req.channel.loadFlags |= Components.interfaces.nsIRequest.LOAD_BYPASS_CACHE;
  139.         req.onreadystatechange = function (aEvt) {  };
  140.         req.send(null);
  141.         //Disabling suggest server button;
  142.         document.getElementById('Ph.Option.Tab1.Tab2.button1').disabled = true;
  143.     },
  144.     
  145.     change_default_server : function (label, value) {
  146.       document.getElementById('PhtxtURL').value = label;
  147.       
  148.       switch (value) {
  149.         case "0.4": document.getElementById('Ph.Option.Tab1.Tab1.pop').selectedIndex=1; break; 
  150.         case "Glype1": document.getElementById('Ph.Option.Tab1.Tab1.pop').selectedIndex=2; break; 
  151.         case "Glype2": document.getElementById('Ph.Option.Tab1.Tab1.pop').selectedIndex=3; break; 
  152.         default: document.getElementById('Ph.Option.Tab1.Tab1.pop').selectedIndex=0;
  153.       }
  154.     },
  155.     
  156.     restore_default_server : function () {
  157.       document.getElementById('PhtxtURL').value = PhProxy_prefs.read_str('facURL');
  158.       var pop = document.getElementById('Ph.Option.Tab1.Tab1.pop');
  159.       switch(PhProxy_prefs.read_str('facType')){
  160.         case "0":
  161.           pop.selectedIndex = 1; 
  162.           break; 
  163.         case "2":
  164.           pop.selectedIndex = 2; 
  165.           break; 
  166.         case "3":   
  167.           pop.selectedIndex = 3; 
  168.           break; 
  169.         default:    
  170.           pop.selectedIndex = 0;
  171.       }
  172.     },
  173.     
  174.     restore_default_controllers : function () {
  175.       with (document) {
  176.         getElementById('Ph.Option.Tab2.Check1').checked = false;
  177.         getElementById('Ph.Option.Tab2.Check2').checked = true;
  178.         getElementById('Ph.Option.Tab2.Check3').checked = true;
  179.         getElementById('Ph.Option.Tab2.Check4').checked = true;
  180.         getElementById('Ph.Option.Tab2.Check5').checked = true;
  181.         getElementById('Ph.Option.Tab2.Check6').checked = false;
  182.         getElementById('Ph.Option.Tab2.Check7').checked = false;
  183.         getElementById('Ph.Option.Tab2.Check8').checked = true;
  184.         getElementById('Ph.Option.Tab2.Check15').checked = true;
  185.         getElementById('Ph.Option.Tab3.Check1').checked = true;
  186.       }
  187.     },
  188.  
  189.     change_addressbar_icon : function (status) {
  190.       var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  191.         .getService(Components.interfaces.nsIWindowMediator);
  192.       var browserEnumerator = wm.getEnumerator("navigator:browser");
  193.       while(browserEnumerator.hasMoreElements()) {   //maybe more than 1 window opens!!
  194.         var document = browserEnumerator.getNext().document;        
  195.         document.getElementById('urlbar').setAttribute('phproxy-show-icon', status);        
  196.       }
  197.       PhProxy_prefs.write_str('showAddressbar', status);
  198.     },
  199.     
  200.     edit_one_server : function () {
  201.       var notificationbox = document.getElementById('notServerUpdating');  
  202.       notificationbox.removeAllNotifications("true"); //Remove all notifications
  203.        
  204.       if (!document.getElementById('Ph.Option.Tab3.txt').value)    
  205.         notificationbox.appendNotification(this.stringsBundle.getString('Alert8'),'','',notificationbox.PRIORITY_CRITICAL_BLOCK);
  206.       else if(document.getElementById('Ph.Option.Tab3.List').selectedIndex == -1)
  207.         notificationbox.appendNotification(this.stringsBundle.getString('Alert9'),'','',notificationbox.PRIORITY_CRITICAL_BLOCK);
  208.       else {
  209.         var txtData = document.getElementById('Ph.Option.Tab3.txt').value;
  210.         if(txtData.substr(txtData.length-1,1) != '/') 
  211.           txtData += '/'; 
  212.         var selected = document.getElementById('Ph.Option.Tab3.List')
  213.           .getItemAtIndex(document.getElementById('Ph.Option.Tab3.List').selectedIndex)
  214.           .getElementsByTagName('listcell');
  215.         
  216.         selected.item(0).setAttribute('label', txtData);
  217.         selected.item(1).setAttribute('label', document.getElementById('Ph.Option.Tab3.lst').label);
  218.       }
  219.     },
  220.     delete_one_server : function () {
  221.       var notificationbox = document.getElementById('notServerUpdating');  
  222.       notificationbox.removeAllNotifications("true"); //Remove all notifications
  223.       
  224.       if (document.getElementById('Ph.Option.Tab3.List').selectedIndex == -1)
  225.         notificationbox.appendNotification(this.stringsBundle.getString('Alert10'),'','',notificationbox.PRIORITY_CRITICAL_BLOCK);
  226.       else {
  227.         var selected = document.getElementById('Ph.Option.Tab3.List')
  228.           .getItemAtIndex(document.getElementById('Ph.Option.Tab3.List').selectedIndex)
  229.           .getElementsByTagName('listcell');
  230.         
  231.         selected.item(0).setAttribute('label', this.stringsBundle.getString('delTab3'));
  232.         selected.item(1).setAttribute('label', "0.5b2");
  233.       }
  234.     },
  235.     
  236.     change_preview_image : function (index) {
  237.       var PhStatusLabel = document.getElementById('PhStatusLabel');
  238.       var PhStatusIMG = document.getElementById('PhStatusIMG');
  239.       
  240.       PhStatusLabel.hidden = false;
  241.       if (index == 0)
  242.         PhStatusIMG.src = 'chrome://inbasicph/skin/InStatus.png';
  243.       else if (index == 1)
  244.         PhStatusIMG.src = 'chrome://inbasicph/skin/InPopUp.png';
  245.       else {
  246.               PhStatusLabel.hidden = true;
  247.         PhStatusIMG.src = '';
  248.       }
  249.     },
  250.     
  251.     apply : function () {
  252.       var notificationbox = document.getElementById('notProxySetup');  
  253.       document.getElementById("PhOption").showPane(document.getElementById("proxySetup")); //Switch to first tab
  254.       notificationbox.removeAllNotifications("true"); //Remove all notifications
  255.  
  256.       /*  Save Tab 1 */      
  257.       var txtData= document.getElementById('PhtxtURL').value;
  258.       if (txtData == this.stringsBundle.getString('delTab3')){
  259.         notificationbox.appendNotification(this.stringsBundle.getString('Alert11'),'','',notificationbox.PRIORITY_CRITICAL_BLOCK);
  260.         return;
  261.       }
  262.       else if (!(!txtData || txtData == this.stringsBundle.getString('txtTab1'))) {
  263.         if(txtData.substr(txtData.length-1,1)!='/') 
  264.           txtData=txtData+ '/'; 
  265.         PhProxy_prefs.write_str('curURL',txtData);    
  266.         PhProxy_prefs.write_str('PrType',document.getElementById('Ph.Option.Tab1.Tab1.pop').value+"");  
  267.           
  268.         switch(PhProxy_prefs.read_str('PrType')){
  269.           case "0": strType="0.4"; break; 
  270.           case "2": strType="Glype1"; break; 
  271.           case "3": strType="Glype2"; break; 
  272.           default:  strType="0.5b2";  
  273.         }
  274.         
  275.         document.getElementById('Ph.Option.Tab1.Tab1.lblURL').value=
  276.           this.stringsBundle.getString('lbl1Tab1') + ' ' + PhProxy_prefs.read_str('curURL');
  277.         document.getElementById('Ph.Option.Tab1.Tab1.lblType').value=  
  278.           this.stringsBundle.getString('lbl2Tab1') + strType;
  279.       }
  280.  
  281.       /*  Save Tab 2 */
  282.       with (document) {
  283.         var sCntr = getElementById('Ph.Option.Tab2.Check1').checked?'1':'0';
  284.         sCntr += getElementById('Ph.Option.Tab2.Check2').checked?'|1':'|0';
  285.         sCntr += getElementById('Ph.Option.Tab2.Check3').checked?'|1':'|0';
  286.         sCntr += getElementById('Ph.Option.Tab2.Check4').checked?'|1':'|0';
  287.         sCntr += getElementById('Ph.Option.Tab2.Check5').checked?'|1':'|0';
  288.         sCntr += getElementById('Ph.Option.Tab2.Check6').checked?'|1':'|0';
  289.         sCntr += getElementById('Ph.Option.Tab2.Check7').checked?'|1':'|0';
  290.         sCntr += getElementById('Ph.Option.Tab2.Check8').checked?'|1':'|0';
  291.       }
  292.       PhProxy_prefs.write_str('Contr', sCntr);
  293.       PhProxy_prefs.write_bool('youTubeV', document.getElementById('Ph.Option.Tab2.Check15').checked);
  294.       
  295.       /*  Save Tab 3 */
  296.       with (document) {
  297.         var sURL = 
  298.           getElementById('Ph.Option.Tab3.lst1').getElementsByTagName('listcell').item(0).getAttribute('label') + '|'
  299.             + getElementById('Ph.Option.Tab3.lst1').getElementsByTagName('listcell').item(1).getAttribute('label') + '|'
  300.             + getElementById('Ph.Option.Tab3.lst2').getElementsByTagName('listcell').item(0).getAttribute('label') + '|'
  301.             + getElementById('Ph.Option.Tab3.lst2').getElementsByTagName('listcell').item(1).getAttribute('label') + '|'
  302.             + getElementById('Ph.Option.Tab3.lst3').getElementsByTagName('listcell').item(0).getAttribute('label') + '|'
  303.             + getElementById('Ph.Option.Tab3.lst3').getElementsByTagName('listcell').item(1).getAttribute('label') + '|'
  304.             + getElementById('Ph.Option.Tab3.lst4').getElementsByTagName('listcell').item(0).getAttribute('label') + '|'
  305.             + getElementById('Ph.Option.Tab3.lst4').getElementsByTagName('listcell').item(1).getAttribute('label') + '|'
  306.             + getElementById('Ph.Option.Tab3.lst5').getElementsByTagName('listcell').item(0).getAttribute('label') + '|'
  307.             + getElementById('Ph.Option.Tab3.lst5').getElementsByTagName('listcell').item(1).getAttribute('label') + '|'
  308.             + getElementById('Ph.Option.Tab3.lst6').getElementsByTagName('listcell').item(0).getAttribute('label') + '|'
  309.             + getElementById('Ph.Option.Tab3.lst6').getElementsByTagName('listcell').item(1).getAttribute('label') + '|'
  310.             + getElementById('Ph.Option.Tab3.lst7').getElementsByTagName('listcell').item(0).getAttribute('label') + '|'
  311.             + getElementById('Ph.Option.Tab3.lst7').getElementsByTagName('listcell').item(1).getAttribute('label') + '|'
  312.             + getElementById('Ph.Option.Tab3.lst8').getElementsByTagName('listcell').item(0).getAttribute('label') + '|'
  313.             + getElementById('Ph.Option.Tab3.lst8').getElementsByTagName('listcell').item(1).getAttribute('label');
  314.       }
  315.       PhProxy_prefs.write_str('sURL', sURL);
  316.       
  317.       for (i = 1; i < 9 ; i++) {
  318.         document.getElementById('menu0' + i).label = 
  319.           document.getElementById('Ph.Option.Tab3.lst' + i).getElementsByTagName('listcell').item(0).getAttribute('label');
  320.         document.getElementById('menu0' + i).value = 
  321.           document.getElementById('Ph.Option.Tab3.lst' + i).getElementsByTagName('listcell').item(1).getAttribute('label');
  322.       }
  323.       
  324.       //update menu list in statusbar
  325.       var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator);
  326.       var browserEnumerator = wm.getEnumerator("navigator:browser");
  327.       while(browserEnumerator.hasMoreElements()){ //maybe more than 1 window opens!!  
  328.         var dc = browserEnumerator.getNext().document;
  329.         for (i = 0; i < 8; i++) {
  330.           var menu = dc.getElementById('Ph.Status.PH7.menupopup').getElementsByTagName('menuitem');
  331.           menu[i+1].label = document.getElementById('menu0'+ (i + 1)).label;  //First menuitem is dServer
  332.           menu[i+1].value = document.getElementById('menu0'+ (i + 1)).value;
  333.         }
  334.       }  
  335.       
  336.       PhProxy_prefs.write_str('dServerUpdate', document.getElementById('Ph.Option.Tab2.Radio2').selectedIndex + ""); 
  337.       /*  Save Tab 4 */    
  338.       PhProxy_prefs.write_str('infoShow', document.getElementById('Ph.Option.Tab5.RadioG').selectedIndex + ""); 
  339.       /*  Save Tab 5 */  
  340.       PhProxy_prefs.write_str('LeftClick', document.getElementById('Ph.Option.Tab6.RadioG').selectedIndex + "");  
  341.       //Notify USer  
  342.       notificationbox.appendNotification(this.stringsBundle.getString('Alert13'),'','',notificationbox.PRIORITY_INFO_MEDIUM); 
  343.     }
  344. }
  345.  
  346. /********************************************************************Update Server ******************************************************************/
  347. function phf_update_from_server(){
  348.   var stringsBundle = document.getElementById("Ph.Option.Bundle");  
  349.   document.getElementById('Ph.Option.Tab2.Cmd').label=stringsBundle.getString('btnTab3');
  350.   var UpdateURL=document.getElementById('Ph.Option.Tab3.menuUpdate').value;
  351.   phv_update_servers.get_from_server(UpdateURL);
  352. }
  353.  
  354. var phv_servers_listener = {
  355.   finished : function(data){
  356.     //Try to correct received data even if it contains more lines
  357.     data = data.match(/[^\n]*/).toString();
  358.     var notificationbox = document.getElementById('notServerUpdating');  
  359.     notificationbox.removeAllNotifications("true"); //Remove all notifications
  360.     
  361.     var stringsBundle = document.getElementById("Ph.Option.Bundle");
  362.   
  363.     var sURL=data.split("|");
  364.     for(y=0;y<18;y++){
  365.       if(sURL[y]=='Error loading page'){
  366.         notificationbox.appendNotification(stringsBundle.getString('Alert2'),'','',notificationbox.PRIORITY_CRITICAL_BLOCK);        
  367.         document.getElementById('Ph.Option.Tab2.Cmd').label= stringsBundle.getString('Button1');
  368.         y=18;
  369.       }
  370.       else if(y==0){
  371.         if(!String(sURL[0]).match('InBasic>ServerInUse>PhProxy>Code124587')){
  372.           y=18;
  373.           notificationbox.appendNotification(stringsBundle.getString('Alert3'),'','',notificationbox.PRIORITY_CRITICAL_BLOCK);
  374.           document.getElementById('Ph.Option.Tab2.Cmd').label = stringsBundle.getString('Button1');
  375.         }
  376.       }
  377.       else if(y==1){
  378.         if(parseFloat(PhProxy_prefs.read_str('UpdateVer'))>=parseFloat(sURL[1])){
  379.           y=18;
  380.           notificationbox.appendNotification(stringsBundle.getString('Alert1'),'','',notificationbox.PRIORITY_WARNING_MEDIUM);
  381.           document.getElementById('Ph.Option.Tab2.Cmd').label= stringsBundle.getString('Button1');
  382.         }
  383.       }
  384.       else{      
  385.         document.getElementById('menu0'+(y)/2).label=sURL[y];
  386.         document.getElementById('menu0'+(y)/2).value=sURL[y+1];        
  387.         document.getElementById('Ph.Option.Tab3.lst'+(y)/2).getElementsByTagName('listcell').item(0).setAttribute('label',sURL[y]);
  388.         document.getElementById('Ph.Option.Tab3.lst'+(y)/2).getElementsByTagName('listcell').item(1).setAttribute('label',sURL[y+1]);
  389.         //update menu list in statusbar
  390.         var wm =Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator);
  391.         var browserEnumerator = wm.getEnumerator("navigator:browser");
  392.         while(browserEnumerator.hasMoreElements())  //maybe more than 1 window opens!!
  393.         {   
  394.           var dc = browserEnumerator.getNext().document;         //Fist menu item is dServer
  395.           dc.getElementById('Ph.Status.PH7.menupopup').getElementsByTagName('menuitem')[(y)/2].label = sURL[y];
  396.           dc.getElementById('Ph.Status.PH7.menupopup').getElementsByTagName('menuitem')[(y)/2].value = sURL[y+1];
  397.         }        
  398.         y++;        
  399.         if(y==17){
  400.           notificationbox.appendNotification(stringsBundle.getString('Alert4'),'','',notificationbox.PRIORITY_INFO_MEDIUM);
  401.           document.getElementById('Ph.Option.Tab2.Cmd').label= stringsBundle.getString('Button1');
  402.           PhProxy_prefs.write_str('sURL',sURL[2]+'|'+sURL[3]+'|'+sURL[4]+'|'+sURL[5]+'|'+sURL[6]+'|'+sURL[7]+'|'+sURL[8]+'|'+sURL[9]+'|'+sURL[10]+'|'+sURL[11]+'|'+sURL[12]+'|'+sURL[13]+'|'+sURL[14]+'|'+sURL[15]+'|'+sURL[16]+'|'+sURL[17]);
  403.           
  404.           PhProxy_prefs.write_str('UpdateVer',sURL[1]);
  405.         }
  406.       }
  407.     }
  408.   }
  409. }
  410.  
  411. var phv_update_servers = {
  412.   get_from_server : function(sURL){
  413.     document.getElementById("Ph.Option.Tab2.Prog").value="0";
  414.     var req = new XMLHttpRequest();
  415.     req.onprogress=function(e){
  416.                 document.getElementById("Ph.Option.Tab2.Prog").value=(e.position / e.totalSize)*100;
  417.         }
  418.     req.open("GET", sURL, true);
  419.     req.channel.loadFlags |= Components.interfaces.nsIRequest.LOAD_BYPASS_CACHE; 
  420.     
  421.     req.onreadystatechange = function (aEvt) {  
  422.       if (req.readyState == 4) {
  423.         if(req.status == 200){
  424.           phv_servers_listener.finished(req.responseText);
  425.           document.getElementById("Ph.Option.Tab2.Prog").value="100";
  426.         }
  427.         else
  428.            phv_servers_listener.finished("Error loading page");
  429.       }
  430.     };
  431.     req.send(null);
  432.   }
  433. }
  434.  
  435. /**Read Write Pref */
  436. var PhProxy_prefs  = {
  437.   prefs: Components.classes["@mozilla.org/preferences-service;1"]
  438.       .getService(Components.interfaces.nsIPrefService).getBranch("InBasic.PhProxy."),
  439.   
  440.   read_str : function (id) {
  441.     return this.prefs.getCharPref(id);
  442.   },  
  443.   write_str : function (id, sData) {
  444.     this.prefs.setCharPref(id, sData);
  445.   },
  446.   read_bool : function (id) {
  447.     return this.prefs.getBoolPref(id);
  448.   },  
  449.   write_bool : function (id, sData) {
  450.     this.prefs.setBoolPref(id, sData);
  451.   }
  452. }